<template>
    <div style="width: 100%">
        <el-checkbox-group v-if="!isInstanceSearch" :style="selectStyle" :disabled="isDisable" :options="optionsList"
                           v-model="properties.bindValue"  :props="defaultProps" :max="properties.isMaxNum ? properties.maxNum : undefined"
                           :min="properties.isMinNum ? properties.minNum : undefined"
                           />

        <el-checkbox-group v-if="isInstanceSearch" :style="selectStyle" :disabled="isDisable" :options="optionsList"
                           v-model="properties.searchValue" :props="defaultProps" :max="properties.isMaxNum ? properties.maxNum : undefined"
                           :min="properties.isMinNum ? properties.minNum : undefined"
                            />
    </div>
</template>

<script setup lang="ts" name="YwuFormCheckBox">
import {computed, defineProps, ref} from "vue";
import {doFromInfoValue} from "@/views/bpmn/form/formUtils.ts";

let props = defineProps(['isEdit', 'properties', 'isInstanceSearch', "isDisable", "formBuildList"]);

let isEdit = computed(() => {return props['isEdit']})
let properties = computed(() => {return props['properties']})
let isInstanceSearch = computed(() => {return props['isInstanceSearch']})
let isDisable = computed(() => {return props['isDisable']})
let formBuildList = computed(() => {return props['formBuildList']})

if (properties.value.bindValue === "") {
    properties.value.bindValue = []
}

if (properties.value.searchValue === "") {
    properties.value.searchValue = []
}

let optionsList = ref([])

let defaultProps = computed(() => {
    return {
        label: properties.value.optionLabel,
        value: properties.value.optionValue,
        disabled: properties.value.optionDisable,
    }
})

let selectStyle = computed(() => {
    if (isEdit.value) {
        return "pointer-events: none;width: 100%"
    } else {
        return "width: 100%";
    }
})

function execFunc(resList) {
    optionsList.value = resList
}

init()
function init() {
    doFromInfoValue(properties.value, formBuildList.value, execFunc)
}
</script>

<style scoped lang="less">

</style>